package com.zjs.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * web控制器
 *
 * @author zhu_jinsheng
 * @version 1.0
 * @date 2020/7/15 15:32
 */
@Slf4j
@RestController
@RequestMapping("/web")
public class WebController {
    @PostMapping("/getWebCount")
    public String getWebCount(HttpServletRequest request) {
        HttpSession httpSession = request.getSession();
        Integer count = (Integer) httpSession.getAttribute("webCount");
        if (null == count) {
            httpSession.setAttribute("webCount", 1);
        } else {
            httpSession.setAttribute("webCount", ++count);
        }
        return "webCount：" + httpSession.getAttribute("webCount");
    }
}
